
const http = require('http');

// cookie 就是一个header 服务可以设置， 浏览器也可以设置

const server = http.createServer((req, res) => {
    if (req.url === '/read') {
        let cookie = req.headers['cookie']
        res.end(cookie)
        return
    }
    if (req.url === '/write/read') {
        let cookies = req.headers['cookie'] || 'empty';// name=zf; age=12
        res.end(cookies)
        return
    }
    // 对cookie做一些安全认证 签名 给cookie进行签名
    if (req.url === '/write') {
        res.setHeader('Set-Cookie',['name=ikki; httpOnly=true','age=12']);
        res.end('write ok')
        return
    }
}); 

server.listen(3000);